package atm;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 菜单界面
 */
public class MenuPanel extends JPanel {
    private ATM05 atm05;
    private JButton searchBtn = new JButton(new ImageIcon("images/buttonFind.jpg"));
    private JButton saveBtn = new JButton(new ImageIcon("images/buttonSave.jpg"));
    private JButton getBtn = new JButton(new ImageIcon("images/buttonGet.jpg"));
    private JButton changePwdBtn = new JButton(new ImageIcon("images/buttonModify.jpg"));
    private JButton transferBtn = new JButton(new ImageIcon("转账"));
    private JButton offBtn = new JButton(new ImageIcon("images/buttonOff.jpg"));
    public MenuPanel(ATM05 atm05){
        this.atm05 = atm05;
        this.setLayout(null);
        this.setOpaque(false);
        //查询按钮
        searchBtn.setBounds(30,100,140,50);
        searchBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm05.showPanel("search");
            }
        });
        this.add(searchBtn);
        //存款按钮
        saveBtn.setBounds(30,200,140,50);
        saveBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm05.showPanel("save");
            }
        });
        this.add(saveBtn);
        //取钱按钮
        getBtn.setBounds(30,300,140,50);
        getBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm05.showPanel("get");
            }
        });
        this.add(getBtn);
        //转账按钮
        transferBtn.setBounds(30,400,140,50);
        transferBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm05.showPanel("transfer");
            }
        });
        this.add(transferBtn);
        //改密按钮
        changePwdBtn.setBounds(700,100,140,50);
        changePwdBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm05.showPanel("changePwd");
            }
        });
        this.add(changePwdBtn);
        //退出按钮
        offBtn.setBounds(700,200,140,50);
        offBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                atm05.showPanel("login");
            }
        });
        this.add(offBtn);
    }

}
